package com.moecollege.umiao.ui;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.moecollege.moecollegelib.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;
import com.moecollege.umiao.R;
import com.readystatesoftware.systembartint.SystemBarTintManager;

/**
 * Created by nieyonghui on 15-7-30.
 */
public class TestActivity extends com.moecollege.moecollegelib.ui.MainFrameActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        applyKitKatTranslucency();
        navigationView.addHeaderView(getLayoutInflater().inflate(R.layout.view_global_menu_header,null));
        navigationView.inflateMenu(R.menu.drawer_menu  );
    }

    @Override
    protected List<String> getTabTitles() {
      List<String> titles = new ArrayList<String>();
        titles.add("首页");
        titles.add("视频");
        titles.add("游戏");
        return titles;
    }

    @Override
    protected List<BaseFragment> getPagers() {
        List<BaseFragment> fragments = new ArrayList<BaseFragment>();
        fragments.add(new TestFragment());
        fragments.add(new TestFragment());
        fragments.add(new TestFragment());

        return fragments;
    }

    /**
     * Apply KitKat specific translucency.
     */
    private void applyKitKatTranslucency() {

        // KitKat translucent navigation/status bar.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setTranslucentStatus(true);
            SystemBarTintManager mTintManager = new SystemBarTintManager(this);
            mTintManager.setStatusBarTintEnabled(true);
            mTintManager.setNavigationBarTintEnabled(true);
            mTintManager.setTintColor(0x000099CC);
//            mTintManager.setTintDrawable(UIElementsHelper
//                    .getGeneralActionBarBackground(this));

        }

    }

    @TargetApi(19)
    private void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }
}
